{% extends 'admin/common/base.html' %}
{% block js %}
{{super()}}
<script>
    //图床
    function imagehosting() {
        layer.open({
            type: 2,
            title: '图片管理',
            shade: 0.8,
            maxmin: true,
            shadeClose: true,
            area: ['80%', '90%'],
            content: '{{url_for("admin.image_hosting")}}' //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
        });
    }

    function imagehosting_callback(obj) {
        $('#img').val(obj.img_url)
    }
</script>
{% endblock %}
{% block content %}
<form method="POST">
    {{ form.hidden_tag() }}
    <div class="form-group row">
        <label for="title" class="col-sm-2 col-form-label">标题:</label>
        <div class="col-sm-10">
            {{form.title(id='title',class="form-control")}}
        </div>
    </div>
    <div class="form-group row">
        <label for="desp" class="col-sm-2 col-form-label">描述:</label>
        <div class="col-sm-10">
            {{form.desp(id='desp',class="form-control")}}
        </div>
    </div>
    <div class="form-group row">
        <label for="url" class="col-sm-2 col-form-label">链接:</label>
        <div class="col-sm-10">
            {{form.url(id='url',class='form-control')}}
        </div>
    </div>
    <div class="form-group row">
        <label for="sn" class="col-sm-2 col-form-label">排序:</label>
        <div class="col-sm-10">
            {{form.sn(id='sn',class='form-control')}}
        </div>
    </div>

    <div class="form-group row">
        <label for="img" class="col-sm-2 col-form-label">图片:</label>
        <div class="col-sm-10 input-group">
            {{form.img(id='img',class='form-control',placeholder='800x400')}}
            <div class="input-group-append">
                <button class="btn btn-outline-secondary" type="button" id="button-addon2" onclick="imagehosting()">选择图片</button>
            </div>
        </div>  
    </div>
    <div class="form-group row">
        <label for="state" class="col-sm-2 col-form-label">状态:</label>
        <div class="col-sm-10">
            {{form.state(id='state',class='form-control')}}
        </div>
    </div>

    <div class="form-group row">
        <div class="col-sm-10">
            {{form.submit(class='btn btn-primary')}}
        </div>
    </div>
</form>
{% endblock %}